package com.example.finalframe.service.impl;

import com.example.finalframe.dao.UserDao;
import com.example.finalframe.model.dto.UserDto;
import com.example.finalframe.model.entity.User;
import com.example.finalframe.service.intf.LoginIntf;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service
public class LoginUsePhonePasswordImpl implements LoginIntf {
    @Autowired
    UserDao userDao;

    //使用手机号验证码登录
    @Override
    public UserDto login(String phone, String password) {
        User user = userDao.findUserByUsernameAndByPassword(phone,password);
        if(user!=null){
            UserDto userDto = new UserDto();
            BeanUtils.copyProperties(user, userDto);
            return userDto;
        }
        return null;
    }
}
